   <!DOCTYPE html>
<html>
<head>
<head />
<div th:include="base-libs :: base-libs" />
<title>新建理事会</title>
<style type="text/css">
.topBtn{
	float: right;
	margin-right:10px;
	margin-top:5px
}
.laydate-icon{
	border:1px solid #b6b6b6
}
</style>
</head>
<script th:inline="javascript">
	/**用户信息*/
	var userInfo = [[${userInfo}]];
</script>
<script type="text/javascript">
	var qysqxx;
	var qyjgxx;
	
	$(function() {
		$(this).registerManagerPage();
		initView();
		initData(); 
	});

	function initData() {
		/**加载初始化信息*/
		$("#CZRYXM").text(userInfo["XM"]);
		$("#CZRYID").val(userInfo["USERID"]);
	}

	function initView() {
		$("#jgxxTable").datagrid(getOption());
		/**选择医联体*/
		$("#xzYlt").on("click", function(){
			//页面层
			var cache = {};
			cache["YLTID"] = $("#YLTID").val();
			cache["ZDYLJGID"] = userInfo["PTJGID"];
			StoreCache.setCache("FWGL_YLTXX", cache);
			parent.layer.open({
				type: 2,
		  		area: ["80%", "500px"], //宽高
		  		scrollbar: false,
		  		resize: false,
				move: false,
				title:"医联体信息列表",
				content: contextRoot + "fwgl/" +"ylt.html",
				end: function () {
					var info = StoreCache.removeCache("FWGL_YLTXX");
					if(info){
						/**加载数据*/
						$("#jgxxTable").datagrid(getOption(info["qysqxx"]["YLTLX"]));
						initYlt(info);
					} 
				}
			});
		});
		
		/**选择理事长*/
		$("#xzLsz").on("click",function(){
			yljgry("lsz");
		});
		
		/**选择理事*/
		$("#xzLs").on("click",function(){
			yljgry("ls");
		});
		
		/**提交按钮*/
		$("#btnSave").on("click", function(){
			if($(".form-control").QuickValidate()){
				var params = {};
				$.QuickRemote.AjaxFiledFormSubmit("managerForm", function(result) { 
					var info = result["info"];
					if (result["state"]) {
						$.QuickAlert.alertNormal("新建医联体成功！",{callback: function(){
							$.QuickUrlUtils.redirectUrl("index.html");
						}});
					} else {
						$.QuickAlert.alertFail({
							content : info["faultInfo"]
						});
					}
				}, params);
			}
		});
		
	}

	function yljgry(lx){
		var cache = {};
		if(lx=="lsz"){
			cache["USERID"] = $("#LSZID").val();
		}else{
			cache["USERID"] = $("#LSIDS").val();
		}
		cache["PTJGID"] = userInfo["PTJGID"];
		cache["LX"] = lx;
		StoreCache.setCache("LSHGL_YLJGRYXX", cache);
		parent.layer.open({
			type: 2,
	  		area: ["80%", "500px"], //宽高
	  		scrollbar: false,
	  		resize: false,
			move: false,
			title:"人员信息列表",
			content: contextRoot + "lshgl/" +"yljgry.html",
			end: function () {
				var info = StoreCache.removeCache("LSHGL_YLJGRYXX");
				if(info){
					/**加载数据*/
					if(lx=="lsz"){
						$("#LSZXM").val(info["XM"]);
						$("#LSZID").val(info["USERID"]);
					}else{
						$("#LSXMS").val(info["XM"]);
						$("#LSIDS").val(info["USERID"]);
					}
				} 
			}
		});
	}
	
	
	
	/**加载医联体信息*/
	function initYlt(info){
		var qysqxx = info["qysqxx"];
		var qyjgxx = info["jsjglb"]; 
		initQysqxx(qysqxx,qyjgxx);
		initQyjgxx(qyjgxx);
	}
	
	
	/**返回按钮*/
	function btnBackHandler() {
		$.QuickUrlUtils.redirectUrl("index.html");
	}
	
	/**加载医联体信息*/
	function initQysqxx(qysqxx,qyjgxx){
		if(qysqxx){
			var info;
			$(qyjgxx).each(function(index,item){
				if(item["JGLX"]=="3"){
					info = item;
				}
			});
			info = $.extend({}, qysqxx, info);
			$(".yltxx").each(function(){
				$(this).text(info[$(this).attr("id")]);
				$(this).val(info[$(this).attr("id")]);
			});
			
		}
	}
	
	/**加载签约机构信息*/
	function initQyjgxx(qyjgxx){
		if(qyjgxx){
			initJgxx(qyjgxx);
		}
	}
	
	/**获取option*/
	function getOption(lx){
		var opt;
		if(lx == "03"){
			opt= {
					idField : "PTJGID",
					uniqueId: "PTJGID",
					striped : true,
					border:false,
					clickToSelect: true,
					fit: true,
					fitColumns: true,
					singleSelect: false,
					rownumbers: true,
					columns : [[
						{
							field : "YLJGMC",
							width: 160,
							align: "center",
							title : "机构名称"
						},
						{
							field : "XZQHMC",
							width: 100,
							align: "center",
							title : "所属区域"
						},
						{
							field : "WSJGLBMC",
							width: 120,
							align: "center",
							title : "机构类型"
						},
						{
							field : "KSMC",
							width: 200,
							align: "center",
							title : "科室",
							formatter : function(value, row, index){
								return "<span title='"+value+"'>"+value+"</span>";
							}
						},
						{
							field : "YYDJMC",
							width: 100,
							align: "center",
							title : "医院等级"
						},
						{
							field : "JGFLGLMC",
							width: 120,
							align: "center",
							title : "经营性质"
						}
					]],onLoadSuccess: function(data){
						$("#jgxxLayout").layout("resize");
					}
				};
		}
		else{
			opt= {
					idField : "PTJGID",
					uniqueId: "PTJGID",
					striped : true,
					border:false,
					clickToSelect: true,
					fit: true,
					fitColumns: true,
					singleSelect: false,
					rownumbers: true,
					columns : [[
						{
							field : "YLJGMC",
							width: 250,
							align: "center",
							title : "机构名称"
						},
						{
							field : "XZQHMC",
							width: 150,
							align: "center",
							title : "所属区域"
						},
						{
							field : "WSJGLBMC",
							width: 150,
							align: "center",
							title : "机构类型"
						},
						{
							field : "YYDJMC",
							width: 150,
							align: "center",
							title : "医院等级"
						},
						{
							field : "JGFLGLMC",
							width: 150,
							align: "center",
							title : "经营性质"
						}
					]],onLoadSuccess: function(data){
						$("#jgxxLayout").layout("resize");
					}
				};
		}
		return opt;
	}
	
	/**初始化选择机构table*/
	function initJgxx(qyjgxx){
		var ary = [];
		if(qyjgxx){
			ary = qyjgxx;
		}
		var length = 37*(ary.length);
		$("#maxDiv").css("height",length+430+"px");
		$("#maxLayout").layout("resize");
		$("#jgxxBody").css("height", length + 43+"px");
		$("#jgxxTable").datagrid("loadData",{"total": ary.length, "rows": ary});
	}
</script>

<body style="overflow-y: scroll">
<div id="maxDiv" style="height: 430px;">
	<div id="maxLayout" class="easyui-layout" fit="true">
		<div region="north" style="border: none; overflow: hidden;height:255px">
			<h4 class="h4-title" style="font-size: 18px;">
				新增理事会
			</h4>
			<div class="form-table-box" >
				<form id="managerForm" class="form-horizontal" action="save">
					<input id="method" name="method" style="display: none;" value="add">
					<table class="form-table">
						<tr>
							<td class="td-text">
								<label>医联体名称</label>
							</td>
							<td class="td-content">
								<input id="YLTID" name="YLTID" class="yltxx" style="display: none;"/>
								<input id="YLTMC" class="form-control dataField yltxx" type="text" style="width: 50%;"
									readonly="readonly" quick-config="label:'医联体名称', validateProxy:'notNull length', length: '50'" 
									placeholder="医联体名称">
								<!-- 按钮触发模态框 -->
								<button class="btn" type="button"  style="width: 40%;"  id="xzYlt">选择</button>
						
							</td>
							<td class="td-text">
								<label>医联体类型</label>
							</td>
							<td class="td-content">
								<span id="YLTLXMC" class="yltxx"></span>
							</td>
							<td class="td-text">
								<label>签约有效期</label>
							</td>
							<td class="td-content">
								<span id="QYYXQMC" class="yltxx"></span>
							</td>
							<td class="td-text">
								<label>主导医疗机构</label>
							</td>
							<td class="td-content">
								<span id="ZDYLJGMC" class="yltxx"></span>
							</td>
						</tr>
						<tr>
							
							<td class="td-text">
								<label>理事会名称</label>
							</td>
							<td class="td-content">
								<input id="LSHMC" name="LSHMC" class="form-control " 
									quick-config="label:'理事会名称', validateProxy:'notNull'" />
							</td>
							<td class="td-text">
								<label>成立时间</label>
							</td>
							<td class="td-content">
								<input id="CLSJ" name="CLSJ" readonly="readonly" style="height:30px;width:85%;"
									class="form-control laydate-icon" onclick="laydate()"
								quick-config="label:'成立时间', validateProxy:'notNull'" />
							</td> 
							<td class="td-text">
								<label>操作人员</label>
								</td>
							<td class="td-content" colspan="3">
								<span id="CZRYXM"></span>
								<input id="CZRYID" name="CZRYID" style="display:none;"/>
							</td>
						</tr>
						<tr>
							<td class="td-text">
								<label>理事长</label>
							</td>
							<td class="td-content" colspan="7">
								<input id="LSZID" name="LSZID" style="display: none;"/>
								<input id="LSZXM" type="text" style="width: 85.5%;" class="form-control" 
								quick-config="label:'理事长', validateProxy:'notNull'" readonly="readonly">
								<button class="btn" type="button"  style="width: 12%;"  id="xzLsz">选择</button>
							</td>
						</tr>
						<tr>
							<td class="td-text">
								<label>理事成员</label>
							</td>
							<td class="td-content" colspan="7">
								<input id="LSIDS" name="LSIDS" style="display: none;"/>
								<input id="LSXMS" class="" type="text" style="width: 85.5%;" class="form-control" 
								quick-config="label:'理事成员', validateProxy:'notNull'" readonly="readonly">
								<button class="btn" type="button"  style="width: 12%;"  id="xzLs">选择</button>
							</td>
						</tr>
						<tr>
							<td class="td-text">
								<label>办公室</label>
							</td>
							<td class="td-content" colspan="7">
								<input id="BGSDZ" name="BGSDZ"  style="width: 98%"
								class="form-control" quick-config="label:'办公室', validateProxy:'notNull'" />
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		<div region="center" style="border: none;overflow: hidden;">
			<h4 class="h4-title" style="font-size: 13px;">
				机构列表
			</h4>
			<div  id="jgxxBody" style="height:43px;width:96.5%;margin-left:2.5%;">
				<div  id="jgxxLayout" class="easyui-layout" fit="true">
					<div region="center" style="border: none;">
						<table id="jgxxTable" >
									</table>
					</div>
				</div>
			</div>
			<div style="height: 320px;">
				<div class="easyui-layout" fit="true" >
					<div region="center" style="border: none">
						<div class="form-table-box" >
							<table class="form-table">
								<tr>
									<td class="td-text">
										<label>备注说明</label>
									</td>
									<td class="td-content" colspan="5">
										<span id="BZSM" class="yltxx" ></span>
									</td>
								</tr>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div region="south" style="border: none;overflow: hidden;text-align:center;">
			<button class="btn" type="button" id="btnSave">提交</button>
			<button class="btn" type="button" onclick="btnBackHandler()">返回</button>
		</div>
	</div>
</div>
</body>
<script type="text/html" id="tableToolBar">
<a class="tableToolBarBtn" href="javascript:remove(#index#)" style="" title="移除" >移除</a>
</script>
</html>


